package com.hx.io.fileinputstream;

import java.io.*;

/**
 * @author jxlgcmh
 * @create 2019-05-09 16:32
 */
public class Demo1 {
    public static void main(String[] args) {
        //注意，可能出现乱码
        InputStream inputStream = null;
        try {
            File file = new File("d.txt");
            inputStream = new FileInputStream(file);
            int len;
            byte[] buf = new byte[1024];
            while ((len = inputStream.read(buf)) != -1) {
                System.out.println(new String(buf));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
